<?php
/**
 * Created by PhpStorm.
 * User: C。
 * Date: 2019/8/13
 * Time: 9:04
 */
namespace app\home\controller;

use app\common\model\ActiveApply as ActiveApplyModel;

/**
 * 活动报名控制器
 * Class Activeapply
 * @package app\home\controller
 */
class Activeapply extends Base
{
    /**
     * [add  报名]
     * @param
     * @return json
     * @author [C。]
     */
    public function add()
    {
        $mem = $this->user;
        $model = new ActiveApplyModel();
        $param = input('param.');
        try{
            $idcard = is_idcard($param['idcard']);
            if(!$idcard){
                return admin_json(-1, '请填写正确身份证号！');
            }
            if(!check_mobile($param['tel']))
                return admin_json(-2, '请填写正确手机号');
            
            $active = $model->findData($mem['id'],'memid');
            if(!empty($active)){
                return admin_json(-1, '每个账户只能报名一次！');
            }
            $param['memid'] = $mem['id'];
            $model->addData($param);
        }catch(\Exception $e){
            systembug($e->getMessage(),2,'home/Activeapply/add');
            return admin_json(-1, '报名失败'.$e->getMessage());
        }
        return admin_json(1, '报名成功');
    }
    /**
     * [photo  图片]
     * @param
     * @return json
     * @author [C。]
     */
    public function photo()
    {
        $photo = array(
            'http://dd.fushan8.com/images/1.jpg',
            'http://dd.fushan8.com/images/2.jpg',
            'http://dd.fushan8.com/images/3.jpg',
            'http://dd.fushan8.com/images/4.jpg',
            'http://dd.fushan8.com/images/5.jpg',
            'http://dd.fushan8.com/images/6.jpg',
            'http://dd.fushan8.com/images/7.jpg',
            'http://dd.fushan8.com/images/8.jpg',
            'http://dd.fushan8.com/images/9.jpg',
            'http://dd.fushan8.com/images/10.jpg',
            'http://dd.fushan8.com/images/11.jpg',
        );
        return admin_json(1, '获取成功',$photo);
    }
}